#include "Robot.h"
#include <iostream>


Kg MovR::Transport(Item& item){
	if(_sleep || *_currentTime < _usableFrom)
		return 0;

	Kg load = std::min(item.Weight(), Capacity());

	item.Store(load);
	_transported = _total += load;
	if (Capacity() < _capacity / 10)
		_charged = false;
	_lastActionAt = item.ArrivedAt();
	return load;
}

bool MovR::Charge(const TimeStamp& endTime){
	if (_charged) return false;
	_charged = true;
	_transported = 0;
	_lastActionAt = *_currentTime;
	_usableFrom = endTime;
	return true;
}

bool operator<(const MovR& lhs, const MovR& rhs){
	return lhs.Capacity() < rhs.Capacity();
}

void PowR::Mount(const TimeStamp& endTime){
	_usableFrom = endTime;
}